#include "sceneanimation.h"
#include <QtGui>
#include <QtDebug>

QPen shotgunpen(Qt::blue);
QPen waveblastpen(Qt::red);

int shotgunPts[2][100] = {0};
int shotguncounter = 0;
int lastcoord[2] = {0};


/**********************
 * Animation for special bubbles
 */
SceneAnimation::SceneAnimation()
{
    shotgunpen.setWidth(4);
    waveblastpen.setWidth(2);
    for(int i = 0; i < 100; i++){
        shotgunPts[0][i] = 1 + (qrand() % 500);
        shotgunPts[1][i] = 1 + (qrand() % 500);
        while((shotgunPts[0][i]*shotgunPts[0][i] + shotgunPts[1][i]*shotgunPts[1][i]) > 250000){
            shotgunPts[0][i] = 1 + (qrand() % 500);
            shotgunPts[1][i] = 1 + (qrand() % 500);
        }
        shotgunPts[0][i] = shotgunPts[0][i] - 250;
        shotgunPts[1][i] = shotgunPts[1][i] - 250;
    }
}


/**********************
 * Draws shotgun animation
 */
void SceneAnimation::shotgun(QPainter *painter, int x, int y)
{
    if(x == -500 && y == -500){
        x = lastcoord[0];
        y = lastcoord[1];
    } else {
        lastcoord[0] = x;
        lastcoord[1] = y;
    }
    painter->save();
    painter->translate(x, y);
    painter->setPen(shotgunpen);
    for(int i = 0; i < 100; i++){
        painter->drawPoint(shotgunPts[0][i], shotgunPts[1][i]);
    }
    painter->restore();
}


/**********************
 * Draws wave-destruction animation
 */
void SceneAnimation::waveout(QPainter *painter, int x, int y)
{
    if(x == -500 && y == -500){
        x = lastcoord[0];
        y = lastcoord[1];
    } else {
        lastcoord[0] = x;
        lastcoord[1] = y;
    }
    painter->save();
    painter->setPen(waveblastpen);
    painter->translate(x, y);
    for(int i = 1; i < 26; i++){
        painter->drawEllipse((-50*i), (-50*i), 100*i, 100*i);
    }
    painter->restore();
}
